script_enemy_main{

let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;
let GRboss=("\script\Images\CharacterSprites\Tomomi.png");

@Initialize{
	LoadGraphic(GRboss);

if(GetArgument==0){
	SetColor(0,200,255);
	Concentration01(90);
	SetColor(255,255,255);
}
	SetLife(10000);
	MagicCircle(false);
	SetInvincibility(120);
	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetMovePosition02(cx+100,miny+100,60);
}
	
@MainLoop{

SetCollisionB(GetX,GetY,16);

if(time%20==0 && time>=90){ SetMovePosition02(cx-100*cos(time+90),miny+100+40*sin(time+90),50); }



//=============================================================

if(GetCommonData("Difficulty")==2){
	if((time+120)%600==0 && time>=90){
	let angle=GetAngleToPlayer-45;
	let color=rand_int(1,3);
		loop(4){
		CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Familiar.txt"),GetX,GetY,0,0,[1,angle,color]);
		angle+=30;
		}
	usespell=-20;
	}
	if((time+420)%600==0 && time>=90){
	let angle=GetAngleToPlayer-45;
	let color=rand_int(1,3);
		loop(4){
		CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Familiar.txt"),GetX,GetY,0,0,[2,angle,color]);
		angle+=30;
		}
	usespell=-20;
	}
} //Normal

//=============================================================

if(GetCommonData("Difficulty")==3){
	if((time+120)%600==0 && time>=90){
	let angle=GetAngleToPlayer-50;
	let color=rand_int(1,3);
		loop(5){
		CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Familiar.txt"),GetX,GetY,0,0,[1,angle,color]);
		angle+=25;
		}
	usespell=-20;
	}
	if((time+420)%600==0 && time>=90){
	let angle=GetAngleToPlayer-50;
	let color=rand_int(1,3);
		loop(5){
		CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Familiar.txt"),GetX,GetY,0,0,[2,angle,color]);
		angle+=25;
		}
	usespell=-20;
	}
} //Hard

//=============================================================

if(GetCommonData("Difficulty")==4){
	if((time+120)%600==0 && time>=90){
	let angle=GetAngleToPlayer-40;
	let color=rand_int(1,3);
		loop(5){
		CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Familiar.txt"),GetX,GetY,0,0,[1,angle,color]);
		angle+=20;
		}
	usespell=-20;
	}
	if((time+420)%600==0 && time>=90){
	let angle=GetAngleToPlayer-40;
	let color=rand_int(1,3);
		loop(5){
		CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Royal Flush - Familiar.txt"),GetX,GetY,0,0,[2,angle,color]);
		angle+=20;
		}
	usespell=-20;
	}
} //Lunatic


time++;
frame++;

if(GetCommonData("UseSpell1")!=0){ usespell=GetCommonData("UseSpell1"); SetCommonData("UseSpell1",0); }
if(usespell>0){ usespell--; }
if(usespell<0){ usespell++; }

SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
	CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,"Tomomi");
	if(GetLife>0 && GetTimer>0){ CreateEnemyFromFile((GetCurrentScriptDirectory~"Tomomi-Takeo - Splashing The Pot - Tomomi.txt"),GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,1); }
}

}